package com.ml.ws;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class IMServiceImpl {

	@RequestMapping(value = "/im/xml", method = RequestMethod.POST)
	@ResponseBody
	public XmlBean test(XmlBean xmlbean, HttpServletRequest request,
			HttpServletResponse response) {

		System.out.println(xmlbean);
		
		return xmlbean;
	}
	
	@RequestMapping(value = "/im/string/{msg}", method = RequestMethod.POST)
	@ResponseBody
	public String test(@PathVariable String msg, HttpServletRequest request,
			HttpServletResponse response) {

		System.out.println(msg);
		
		return "recive msg : "+msg;
	}
	
	@RequestMapping(value = "/im/create", method = RequestMethod.POST)
	@ResponseBody
	public IMReport create(HttpServletRequest request,
			HttpServletResponse response, IMCustomer customer) {

		// TODO
//		IMHelper.create(customer);

		IMReport ir = new IMReport();
		ir.setO_status("200");
		ir.setO_retmsg("do create !");
		ir.setCustomer(customer);
		return ir;
	}
	
	@RequestMapping(value = "/im/modify", method = RequestMethod.POST)
	@ResponseBody
	public IMReport modify(HttpServletRequest request,
			HttpServletResponse response, IMCustomer customer) {

		// TODO
//		IMHelper.modify(customer);
		
		IMReport ir = new IMReport();
		ir.setO_status("200");
		ir.setO_retmsg("do modify !");
		ir.setCustomer(customer);
		return ir;
	}
	
	@RequestMapping(value = "/im/delete", method = RequestMethod.POST)
	@ResponseBody
	public IMReport delete(HttpServletRequest request,
			HttpServletResponse response, IMCustomer customer) {

		// TODO
//		IMHelper.delete(customer);

		IMReport ir = new IMReport();
		ir.setO_status("200");
		ir.setO_retmsg("do delete !");
		ir.setCustomer(customer);
		return ir;
	}

	@RequestMapping(value = "/im/find", method = RequestMethod.GET)
	@ResponseBody
	public IMReport find(HttpServletRequest request,
			HttpServletResponse response, String memberID, String clientID) {
		// TODO
//		IMHelper.find(memberID, clientID);

		IMReport ir = new IMReport();
		ir.setO_status("200");
		ir.setO_retmsg("do find !");
		IMCustomer customer = new IMCustomer();
		customer.setMemberID(memberID);
		customer.setClientID(clientID);
		ir.setCustomer(customer);
		return ir;
	}

	@RequestMapping(value = "/im/review", method = RequestMethod.GET)
	@ResponseBody
	public IMReport find(HttpServletRequest request,
			HttpServletResponse response, String memberID) {
		
		// TODO
//		IMHelper.review(memberID);

		IMReport ir = new IMReport();
		ir.setO_status("200");
		ir.setO_retmsg("do review !");
		IMCustomer customer = new IMCustomer();
		customer.setMemberID(memberID);
		ir.setCustomer(customer);
		return ir;
	}
	
//	public static void main(String[] args) {
//		System.out.println(BCrypt.hashpw("ml", BCrypt.gensalt()));
//	}
	
}
